package com.topscomm.pm.script;

import com.topscomm.cbo.pojo.CboApprovalNodeInsEntity;
import com.topscomm.pm.PmScript;
import com.topscomm.pm.pojo.PmPurchaseContractEntity;
import com.topscomm.pm.service.impl.PmPurchaseContractService;
import com.topscomm.pub.util.ConvertUtil;
import com.topscomm.pub.util.SpringUtil;
import com.topscomm.pub.util.StringBufferProxy;
import com.topscomm.tap.ITapService;
import com.topscomm.tap.TapEntity;

import java.math.BigDecimal;

/**
 * @author: shenyouyi
 * @date: 2020/6/3
 * @description:
 */
public class PmPurchaseContractScript extends PmScript {

    /**
     * 回写项目采购合同金额字段
     * @param service
     * @param entity
     */
    public void updatePurchasecontractmoneyOfProject(ITapService service, TapEntity entity) {
        // 采购合同申请审批通过后，查询当前采购合同金额，将该值加到项目的 purchasecontractmoney 中去
        CboApprovalNodeInsEntity nodeIns = (CboApprovalNodeInsEntity) entity;
        String sourceId = ConvertUtil.convertToString(nodeIns.getSourceid());
        PmPurchaseContractService pmPurchaseContractService = (PmPurchaseContractService) SpringUtil.getBean("pmPurchaseContractService");
        pmPurchaseContractService.updatePurchasecontractmoneyOfProject(sourceId, true);
    }

}
